package com.information.common;

import com.infoland.jfinal.JSONHandler;
import com.information.controller.Controller;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;

public class DemoConfig extends JFinalConfig{
	/**
	 * 配置常量
	 */
	@Override
	public void configConstant(Constants me) {
		//开发模式
		me.setDevMode(true);
		
	}
	/**
	 * 配置路由
	 */
	@Override
	public void configRoute(Routes me) {
		me.add("/",Controller.class);
		
	}
	/**
	 * 配置模板
	 */
	@Override
	public void configEngine(Engine me) {
		// TODO Auto-generated method stub
		
	}
	/**
	 * 配置插件
	 */
	@Override
	public void configPlugin(Plugins me) {
		String url="jdbc:mysql://localhost:3306/population_information";
		String username="root";
		String password="123456";
		DruidPlugin dp=new DruidPlugin(url, username, password);
		me.add(dp);
		ActiveRecordPlugin arp=new ActiveRecordPlugin(dp);
		me.add(arp);
	}
	/**
	 * 配置拦截器
	 */
	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}
	/**
	 * 配置控制器
	 */
	@Override
	public void configHandler(Handlers me) {
		me.add(new JSONHandler()); 
	}
	public static void main(String[] args) {
	    // eclipse �µ�������ʽ
	    JFinal.start("src/main/webapp", 80, "/", 5);
	    
	    // IDEA �µ�������ʽ
	    // JFinal.start("src/main/webapp", 80, "/");
	}

}
